<!-- src/components/common/VideoCard.vue -->
<template>
  <div class="video-card" @click="navigateToVideo">
    <div class="video-thumbnail">
      <img :src="video.thumbnail" :alt="video.title">
      <span class="video-duration">{{ video.duration }}</span>
      <div class="video-overlay">
        <i class="el-icon-video-play play-icon"></i>
      </div>
    </div>
    <div class="video-info">
      <h3 class="video-title">{{ video.title }}</h3>
      <div class="video-meta">
        <span class="video-category">{{ video.category }}</span>
        <span class="video-views">{{ video.views }}次观看</span>
      </div>
      <p class="video-desc">{{ video.description }}</p>
    </div>
  </div>
</template>

<script>
export default {
  name: 'VideoCard',
  props: {
    video: {
      type: Object,
      required: true
    }
  },
  methods: {
    navigateToVideo() {
      this.$router.push(`/video/${this.video.id}`)
    }
  }
}
</script>

<style scoped>
.video-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.video-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.video-thumbnail {
  position: relative;
  padding-top: 56.25%; /* 16:9 比例 */
}

.video-thumbnail img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-duration {
  position: absolute;
  bottom: 0.8rem;
  right: 0.8rem;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
}

.video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.video-card:hover .video-overlay {
  opacity: 1;
}

.play-icon {
  font-size: 3rem;
  color: white;
}

.video-info {
  padding: 1.2rem;
}

.video-title {
  font-size: 1.1rem;
  margin: 0 0 0.8rem;
  color: #1a1a1a;
  line-height: 1.4;
}

.video-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.8rem;
  font-size: 0.9rem;
  color: #666;
}

.video-desc {
  font-size: 0.9rem;
  color: #666;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}
</style> 